/**
 * =============================================================================
 * ************   Fab 浮动操作按钮   ************
 * =============================================================================
 */

@fab-size: 56px;
@fab-size-mini: 40px;

/* 浮动操作按钮 */
.mdui-fab {
  border-radius: 50%;
  font-size: 24px;
  margin: auto;
  padding: 0 !important;
  overflow: hidden;
  line-height: normal !important;
  .mdui-shadow(6);

  height: @fab-size;
  width: @fab-size;
  min-width: @fab-size;

  &:hover{
    .mdui-shadow(8);
  }

  &:active {
    .mdui-shadow(12);
  }

  // 浮动操作按钮中的图标
  .mdui-icon {
    position: absolute;
    top: 0;
    left: 0;
    line-height: 24px;
    width: 24px;
    margin-left: 16px;
    margin-top: 16px;
  }
}

/* mini 型浮动操作按钮 */
.mdui-fab-mini {
  height: @fab-size-mini;
  width: @fab-size-mini;
  min-width: @fab-size-mini;

  // mini 型浮动操作按钮中的图标
  .mdui-icon {
    margin-left: 8px;
    margin-top: 8px;
  }
}

/* 固定到右下角的 FAB 按钮 */
.mdui-fab-fixed,
.mdui-fab-wrapper {
  position: fixed !important;

  /* 手机平板上距离屏幕右下角 16px */
  right: 16px;
  bottom: 16px;

  @media (min-width: @screen-md-min) {
    /* 电脑上距离屏幕右下角 24px */
    right: 24px;
    bottom: 24px;
  }
}

/* 含菜单的浮动操作按钮 */
.mdui-fab-wrapper {
  position: relative;
  width: @fab-size;
  height: @fab-size;
  padding-top: 8px;
  z-index: @z-index-fab;
  text-align: center;

  // 菜单打开前
  &>.mdui-fab {
    .mdui-icon:not(.mdui-fab-opened) {
      will-change: opacity, transform;
      transition: all .2s @animation-curve-default;
      opacity: 1;
    }
    .mdui-icon.mdui-fab-opened {
      will-change: opacity, transform;
      transition: all .2s @animation-curve-default;
      opacity: 0;
      transform: rotate(225deg);
    }
  }

  // 菜单打开后
  &>.mdui-fab.mdui-fab-opened {
    .mdui-icon:not(.mdui-fab-opened) {
      opacity: 0;
      transform: rotate(225deg);
    }
    .mdui-icon.mdui-fab-opened {
      opacity: 1;
      transform: rotate(360deg);
    }
  }

  // mini 按钮需要垂直居中
  &>.mdui-fab-mini {
    margin-top: (@fab-size - @fab-size-mini) / 2;
  }

  .mdui-fab-dial {
    visibility: visible;
    position: absolute;
    left: 0;
    right: 0;
    bottom: @fab-size + 8px;
    text-align: center;
    height: 0;

    .mdui-fab {
      margin: 8px 0;
      transition: box-shadow .2s @animation-curve-fast-out-linear-in,
                  color .2s @animation-curve-default,
                  // fab
                  transform 150ms @animation-curve-default,
                  opacity 150ms @animation-curve-default;
      transform: scale(0);
      opacity: 0;
    }

    &.mdui-fab-dial-show {
      .mdui-fab {
        transform: scale(1);
        opacity: 1;
      }
    }
  }
}

/* 添加类 .mdui-fab-hide 以动画的形式隐藏按钮 */
.mdui-fab,
.mdui-fab-mini,
.mdui-fab-wrapper {
  will-change: transform;
  transition: all .2s @animation-curve-default,
              box-shadow .2s @animation-curve-fast-out-linear-in,
                // fab
              transform .2s;
  transform: scale(1) translateZ(0);

  &.mdui-fab-hide {
    transform: scale(0) translateZ(0);
  }
}
